package com.xhd.base.log.impl;

import com.xhd.server.ServerConfig;

public class LogConfig {
	public static final int TYPE_INFO = 10;
	  public static final int TYPE_ERROR = 20;
	  public static final int TYPE_ACTION = 30;
	  public static final int TYPE_SQL = 40;
	  public static final int TYPE_PROCESS = 50;
	  public static final int TYPE_MSG = 60;
	  public static final int TYPE_EXPORT = 70;
	  public static final int DEBUG = 11;
	  public static final int TRACE = 12;
	  public static final int INFO = 13;
	  public static final int WARN = 21;
	  public static final int ERROR = 22;
	  public static final int FATAL = 23;
	  public static final int ACTION = 31;
	  public static final int SQL = 41;
	  public static final int PROCESS = 51;
	  public static final int MSG = 61;
	  public static final int EXPORT = 71;
	  private static LogConfig logins;

	  public static LogConfig getInstance()
	  {
	    return logins;
	  }

	  public static String getLogFile(int paramInt)
	  {
	    int i = paramInt - (paramInt % 10);
	    String str1 = null;
	    switch (i)
	    {
	    case 10:
	      str1 = ServerConfig.getString("log-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "stdout_";
	      break;
	    case 20:
	      str1 = ServerConfig.getString("errlog-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "errout_";
	      break;
	    case 30:
	      str1 = ServerConfig.getString("actionlog-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "action_";
	      break;
	    case 40:
	      str1 = ServerConfig.getString("dblog-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "stddb_";
	      break;
	    case 60:
	      str1 = ServerConfig.getString("msglog-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "msg_";
	      break;
	    case 70:
	      str1 = ServerConfig.getString("exportlog-file");
	      if ((str1 == null) || (str1.length() < 1))
	        str1 = "export_";
	      break;
	    case 50:
	      str1 = ServerConfig.getString("syslog-vaultid");
	    }
	    if ((str1 != null) && (str1.length() > 0) && (str1.indexOf(58) < 0))
	    {
	      String str2 = ServerConfig.SystemPath + "log";
	      if (str1.charAt(0) == ServerConfig.FILE_SEPARATOR)
	        str1 = str2 + str1;
	      else
	        str1 = str2 + ServerConfig.FILE_SEPARATOR + str1;
	    }
	    return str1;
	  }

	  public static boolean isLog(int paramInt)
	  {
	    int i = paramInt % 10;
	    int j = paramInt - i;
	    int k = 0;
	    switch (j)
	    {
	    case 10:
	      if (ServerConfig.getBoolean("write-log"))
	        k = 1;
	      break;
	    case 20:
	      if (ServerConfig.getBoolean("write-errlog"))
	        k = 1;
	      break;
	    case 30:
	      if (ServerConfig.getBoolean("write-actionlog"))
	        k = 1;
	      break;
	    case 40:
	      if (ServerConfig.getBoolean("write-dblog"))
	        k = 1;
	      break;
	    case 50:
	      if (ServerConfig.getBoolean("write-syslog"))
	        k = 1;
	      break;
	    case 60:
	      if (ServerConfig.getBoolean("write-msglog"))
	        k = 1;
	      break;
	    case 70:
	      if (ServerConfig.getBoolean("write-exportlog"))
	        k = 1;
	    }
	    if (k == 0)
	      return false;
	    return (i >= k);
	  }
}
